package com.zqxq.lottery.cms.controller;

import com.zqxq.common.constant.Result;
import com.zqxq.common.enums.CodeEnum;
import com.zqxq.lottery.cms.feign.LotteryServerFeignClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 苦智
 * @date 2018/9/26 10:15
 * @description 赛事管理
 * @ClassName MatchManageController
 */
@Api(value = "赛事管理",tags = "赛事管理")
@RequestMapping("/match")
@RestController
public class MatchManageController {
    @Autowired
    private LotteryServerFeignClient lotteryServerFeignClient;


    @PostMapping("/leagueList")
    @ApiOperation("获取所有的赛事")
    public Result getAllLeague(){
        return lotteryServerFeignClient.getAllLeague();
    }

    @PostMapping("/matchList")
    @ApiOperation("根据联赛id查找未开始赛事")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "matchTime",value = "开赛时间",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "league",value = "联赛",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "leagueId",value = "联赛id",required = false,dataType = "Long",paramType = "query"),
            @ApiImplicitParam(name = "isHot",value = "热门状态1：热门 0：冷门",required = false,dataType = "Integer",paramType = "query")
    })
    public Result getMatchList(Long leagueId,Integer isHot,String matchTime,String league){
        return lotteryServerFeignClient.getMatchList(leagueId,isHot,matchTime,league);
    }

    @PostMapping("/edit")
    @ApiOperation("编辑赛事")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "赛事id",required = false,dataType = "Long",paramType = "query"),
            @ApiImplicitParam(name = "isHot",value = "热门状态1：热门 0：冷门",required = false,dataType = "Integer",paramType = "query")
    })
    public Result editMatch(Long id ,Integer isHot){
        if (StringUtils.isEmpty(id) || StringUtils.isEmpty(isHot)) {
            return new Result(CodeEnum.FAIL_100002.getCode(), CodeEnum.FAIL_100002.getMsg());
        }
        return lotteryServerFeignClient.editMatchList(id,isHot);
    }


    @PostMapping("/matchResultList")
    @ApiOperation("查询开奖结果")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNo", value = "页码", required = false, paramType = "query", dataType = "Integer", defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = false, paramType = "query", dataType = "Integer", defaultValue = "10"),
            @ApiImplicitParam(name = "id",value = "id",required = false,dataType = "Long",paramType = "query"),
            @ApiImplicitParam(name = "matchTime",value = "开赛时间",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "league",value = "联赛",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "leagueId",value = "联赛id",required = false,dataType = "Long",paramType = "query"),
            @ApiImplicitParam(name = "status",value = "赛事状态0：未开始 1：进行中2：暂停3：已完成4：推迟5：取消",required = false,dataType = "Integer",paramType = "query")
    })
    public Result getMatchResultList(Integer pageNo, Integer pageSize,Long id,Long leagueId,Integer status,String matchTime,String league){
        return lotteryServerFeignClient.getMatchResultList(pageNo,pageSize,id,leagueId,status,matchTime,league);
    }

    /*@ApiOperation(value = "开奖结果-保存", notes="开奖结果-保存")
    @PostMapping("/saveMatchResult")
    public Result saveMatchResult(JczqMatchLiveVO vo){
        return lotteryServerFeignClient.saveMatchResult(vo);
    }*/
}
